import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

public class Main {
    public static void main(String[] args) throws InterruptedException {
        final int backlog=100;
        String host="192.168.0.5";
        int port=8888;
        Socket[] sockets=new Socket[backlog];
        for(int i=0;i<backlog;i++){ //创建100个连接
            try {
                sockets[i]=new Socket(host,port);
                System.out.println("第"+(i+1)+"次连接成功！");
            } catch (UnknownHostException e) {
                e.printStackTrace();
            } catch (IOException e) {
                System.out.println("第"+(i+1)+"次连接失败！");
            }
        }
        for(Socket s:sockets){ //关闭连接
            try {
                s.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}